package com.anli.config;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/30  14:20
 * 描述:
 */
@Component
public class RedisKeyExpireHandler extends KeyExpirationEventMessageListener {



    public RedisKeyExpireHandler(RedisMessageListenerContainer listenerContainer) {
        super(listenerContainer);
    }

    @Override
    public void onMessage(Message message, byte[] pattern) {

        try {

            String s = new String(message.getBody(), "utf-8");
            System.out.println(s);
            System.out.println(new String(pattern,"utf-8"));

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

    }
}
